From 45dc6ad80a811a8ca2decab2d364f9e9a041fbc9 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Mon, 26 Sep 2005 18:49:21 +0100 Subject: [PATCH] xenstore fires @releaseDomain both when a domain shuts down and when it eventually dies. xenconsoled now only relinquishes its handle on a domain when it dies. This allows us to 'xm console' connect to a crashed domain, which is very useful! Signed-off-by: Keir Fraser --- .hgignore | 1 + tools/console/daemon/io.c | 2 +- tools/xenstore/xenstored_domain.c | 21 +++++++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.hgignore b/.hgignore index d3ab962a7a..7dddc93cae 100644 --- a/.hgignore +++ b/.hgignore @@ -158,6 +158,7 @@ ^tools/xenstore/xs_dom0_test$ ^tools/xenstore/xs_random$ ^tools/xenstore/xs_stress$ +^tools/xenstore/xs_tdb_dump$ ^tools/xenstore/xs_test$ ^tools/xenstore/xs_watch_stress$ ^tools/xentrace/xenctx$ diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index cec7f794ce..e4739d977c 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -399,7 +399,7 @@ void enum_domains(void) while (xc_domain_getinfo(xc, domid, 1, &dominfo) == 1) { dom = lookup_domain(dominfo.domid); - if (dominfo.dying || dominfo.crashed || dominfo.shutdown) { + if (dominfo.dying) { if (dom) shutdown_domain(dom); } else { diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index 3732781df9..9ac1b28eef 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -63,6 +63,8 @@ struct domain /* The connection associated with this. */ struct connection *conn; + /* Have we noticed that this domain is shutdown? */ + int shutdown; }; static LIST_HEAD(domains); @@ -222,19 +224,25 @@ static void domain_cleanup(void) { xc_dominfo_t dominfo; struct domain *domain, *tmp; - int released = 0; + int notify = 0; list_for_each_entry_safe(domain, tmp, &domains, list) { if (xc_domain_getinfo(*xc_handle, domain->domid, 1, &dominfo) == 1 && - dominfo.domid == domain->domid && - !dominfo.dying && !dominfo.crashed && !dominfo.shutdown) - continue; + dominfo.domid == domain->domid) { + if ((dominfo.crashed || dominfo.shutdown) + && !domain->shutdown) { + domain->shutdown = 1; + notify = 1; + } + if (!dominfo.dying) + continue; + } talloc_free(domain->conn); - released++; + notify = 1; } - if (released) + if (notify) fire_watches(NULL, "@releaseDomain", false); } @@ -272,6 +280,7 @@ static struct domain *new_domain(void *context, domid_t domid, struct domain *domain; domain = talloc(context, struct domain); domain->port = 0; + domain->shutdown = 0; domain->domid = domid; domain->path = talloc_strdup(domain, path); domain->page = xc_map_foreign_range(*xc_handle, domain->domid, -- 2.30.2